package com.example.sain.wifiapplication;

import android.content.Context;
import android.hardware.input.InputManager;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.InputDevice;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Example of a call to a native method
        TextView tv = (TextView) findViewById(R.id.sample_text);
        tv.setText(CommonDrive.stringFromJNI());

        WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        String macAddress = wifiInfo.getMacAddress();
        Log.i(TAG, "onCreate1: " + macAddress);
        Log.i(TAG, "onCreate2: " + getSnVersion());
        Log.i(TAG, "onCreate3: " + getTPmanufacturer());
        Log.i(TAG, "onCreate4: " + getTPfirmwareVersion());

    }


    private String getSnVersion() {
        String serialNumber = Build.getSerial();
        return serialNumber;

    }


    private String getTPmanufacturer() {
        InputManager inputManager = (InputManager) getSystemService(Context.INPUT_SERVICE);
        InputDevice inputDevice = inputManager.getInputDevice(4);
        return inputDevice.getName();
    }

    private int getTPfirmwareVersion() {
        InputManager inputManager = (InputManager) getSystemService(Context.INPUT_SERVICE);
        InputDevice inputDevice = inputManager.getInputDevice(4);
        Log.i(TAG, "getTPfirmwareVersion: " + inputDevice.getControllerNumber());
        Log.i(TAG, "getTPfirmwareVersion: " + inputDevice.getVendorId());
        return inputDevice.getProductId();
    }


    public void test(View view) {
        Log.i(TAG, "onCreate: " + CommonDrive.getWifiMacAddress());

        WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        String macAddress = wifiInfo.getMacAddress();
        Log.i(TAG, "onCreate: " + macAddress);

        //can't dump BatteryService from from pid=10855, uid=10122 due to missing android.permission.DUMP permission
    }

}
